package com.chainshop.outboundRecords.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chainshop.common.annotation.Log;
import com.chainshop.common.core.controller.BaseController;
import com.chainshop.common.core.domain.AjaxResult;
import com.chainshop.common.enums.BusinessType;
import com.chainshop.outboundRecords.domain.OutboundRecords;
import com.chainshop.outboundRecords.service.IOutboundRecordsService;
import com.chainshop.common.utils.poi.ExcelUtil;
import com.chainshop.common.core.page.TableDataInfo;

/**
 * 出库记录Controller
 * 
 * @author zzd
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/outboundRecords/outboundRecords")
public class OutboundRecordsController extends BaseController
{
    @Autowired
    private IOutboundRecordsService outboundRecordsService;

    /**
     * 查询出库记录列表
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutboundRecords outboundRecords)
    {
        startPage();
        List<OutboundRecords> list = outboundRecordsService.selectOutboundRecordsList(outboundRecords);
        return getDataTable(list);
    }

    /**
     * 导出出库记录列表
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:export')")
    @Log(title = "出库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OutboundRecords outboundRecords)
    {
        List<OutboundRecords> list = outboundRecordsService.selectOutboundRecordsList(outboundRecords);
        ExcelUtil<OutboundRecords> util = new ExcelUtil<OutboundRecords>(OutboundRecords.class);
        util.exportExcel(response, list, "出库记录数据");
    }

    /**
     * 获取出库记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(outboundRecordsService.selectOutboundRecordsById(id));
    }

    /**
     * 新增出库记录
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:add')")
    @Log(title = "出库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutboundRecords outboundRecords)
    {
        return toAjax(outboundRecordsService.insertOutboundRecords(outboundRecords));
    }

    /**
     * 修改出库记录
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:edit')")
    @Log(title = "出库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutboundRecords outboundRecords)
    {
        return toAjax(outboundRecordsService.updateOutboundRecords(outboundRecords));
    }

    /**
     * 删除出库记录
     */
    @PreAuthorize("@ss.hasPermi('outboundRecords:outboundRecords:remove')")
    @Log(title = "出库记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(outboundRecordsService.deleteOutboundRecordsByIds(ids));
    }
}
